package com.junxonline.plat.dao.repository;

import com.junxonline.plat.dao.model.Database;
import com.junxonline.plat.dao.model.DatabaseTable;
import com.junxonline.plat.dao.model.Menu;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: DatabaseRepository
 * @Description: 数据库数据操作类
 * @author JunX
 */
@Repository
public interface DatabaseRepository extends JpaRepository<Database, Long>, JpaSpecificationExecutor<Database> {

    Database findByDatabaseId(Long databaseId);

    @Query(value ="SELECT table_id, table_name FROM sys_database_table WHERE database_id = ?1 ORDER BY database_id ASC;", nativeQuery = true)
    List<Map<String, Object>> findTablesByDatabaseId(Long databaseId);

}
